const Koa = require('koa');
const router = require('koa-router')();
const views = require('koa-views');
// const router = new Router();

const app = new Koa();


// app.use(async (ctx, next) => {
//     console.log(new Date());
//     next();
// })
app.use(views('views', {
    extension: 'ejs'
}))

/** 应用层中间件 */


router.get('/', async (ctx, next) => {
    let title = 'CMS-Koa2';
    let list = ['0', '1', '2', '3', '4', '5'];
    await ctx.render('index', {
        title: title,
        list: list
    });
})

/** 启动路由 */
app.use(router.routes())
app.use(router.allowedMethods());
/** 监听端口 */
app.listen(8080);
